<form id="dialog-add-content" name="authorizeForm" novalidate style="width:1000px;">
    <div class="col-sm-8 clearfix">
        <div class="table-header mt5" style="position: relative; margin-bottom: 10px;">
            <div class="clearfix" style="padding-bottom:4px;">
                <span class="fl f14 lh30 text-indent">激活授权</span>
            </div>
        </div>
        <ul class="authorize-list mt10">
            <li>
                <div class="authorize-title">授权</div>
                <div class="authorize-chart" id="js_authorize_total"></div>
            </li>
        </ul>
        <ul class="authorize-list mt10">
            <li>
                <div class="authorize-title">绑定</div>
                <div class="authorize-chart" id="js_authorize_used"></div>
            </li>
        </ul>
        <ul class="authorize-list mt10">
            <li>
                <div class="authorize-title">可用</div>
                <div class="authorize-chart" id="js_authorize_usable"></div>
            </li>
        </ul>
    </div>
    <div class="col-sm-16">
        <div class="table-header mt5" style="position: relative; margin-bottom: 10px;">
            <div class="clearfix">
                <span class="fl f14 lh30 text-indent">授权列表</span>

                <div class="fr btn-group">
                    <a href="javascript:;" class="btn btn-yellow mr10"
                       ui-dialog="新增"
                       ui-dialog-before-show="onBeforeShowCreateContract(data,$dialog,$dialogScope)"
                       ui-dialog-cache="false"
                       ui-dialog-ok="createContract($data,$dialog,$dialogScope)"
                       ui-dialog-url="${require('./contract.html?url')}">
                        <i class="btn-icon-add"></i>新增
                    </a>
                    <a href="javascript:void(0)" title="项目禁用" class="btn btn-yellow"
                       ui-dialog="项目禁用"
                       ui-dialog-before-show="beforeDisableProject($dialog,$dialogScope)"
                       ui-dialog-url="${require('./disable_project.html?url')}">
                        <i class="icon-op icon-op-edit">&nbsp;</i>
                        <span>项目禁用</span>
                    </a>
                </div>
            </div>
        </div>
        <div style="height:475px;overflow: auto;">
            <div class="table-wrap" ng-class="{'mt10':!$first}"
                 ng-repeat="item in data.contracts">
                <table width="100%">
                    <thead>
                    <tr class="thead ta-l">
                        <th height="34" colspan="3">
                            <span style="margin-right:10px;">{{item.ContractNum}}</span><span>{{item.PartyA}}</span>
                        </th>
                        <th height="34" width="130px" class="operate-btn align-r">
                            <div class="align-l" ng-show="item.Status==1||item.Status==3">
                                <a href="javascript:void(0)" title="编辑" class="mr5"
                                   ui-dialog="编辑授权"
                                   ui-dialog-data="item"
                                   ui-dialog-cache="false"
                                   ui-dialog-before-show="onBeforeShowEditContract(item,$dialog,$dialogScope)"
                                   ui-dialog-ok="editContract($data,$dialog,$dialogScope)"
                                   ui-dialog-url="${require('./contract.html?url')}">
                                    <i class="icon-op icon-op-edit">&nbsp;</i>
                                    <span>编辑</span>
                                </a>
                                <a href="javascript:void(0)" title="作废" ng-click="setAside(item)" class="mr5">
                                    <i class="icon-op icon-op-del">&nbsp;</i>
                                    <span>作废</span>
                                </a>
                                <span ng-if="showRenewal(item)">
                                    <a href="javascript:void(0)" title="续签" class="mr5"
                                       ui-dialog="续签"
                                       ui-dialog-cache="false"
                                       ui-dialog-show="showEditRenewal(item,$dialog,$dialogScope)"
                                       ui-dialog-url="${require('./renewalProject.html?url')}">
                                        <i class="icon-op icon-op-check_grey">&nbsp;</i>
                                        <span>续签</span>
                                    </a>

                                    <a href="javascript:void(0)" title="查看合同已绑项目"
                                       ng-if="areadyBingProjNum(item.packages)"
                                       ui-dialog="查看合同已绑项目"
                                       ui-dialog-show="showAuthorizedProj(item,$dialog,$dialogScope)"
                                       ui-dialog-ok="editAuthorizedProj($data,$dialog,$dialogScope)"
                                       ui-dialog-url="${require('./authorized-proj.html?url')}"
                                    ><i class="icon-op icon-op-add">&nbsp;</i>
                                        <span>已绑</span></a>
                                </span>
                            </div>
                            <div class="align-l" ng-show="item.Status==2">
                                <a class="mr5"
                                   title="删除"
                                   ng-click="removeAuthorize(item)">
                                    <i class="icon-op icon-op-add">&nbsp;</i>
                                    <span>删除</span>
                                </a>
                            </div>
                        </th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr ng-repeat="packageItem in item.packages" ng-if="packageItem.total_num > 0">
                        <td height="60">{{packageItem.friendly_name}}</td>
                        <td>授权：{{packageItem.total_num}}</td>
                        <td ng-if="packageItem.used_num == 0">绑定：{{packageItem.used_num}}</td>
                        <td ng-if="packageItem.used_num > 0">
                            绑定：
                            <span class="enabled-click-bind-record"
                                ui-dialog="项目绑定记录"
                                ui-dialog-show="showBindRecord( data, $dialog, $dialogScope, {
                                    data: item,
                                    unique_name: packageItem.unique_name,
                                    IsQdAdvanced: packageItem.IsQdAdvanced,
                                    orgname: orgname
                                })"
                                ui-dialog-cache="false"
                                ui-dialog-url="${require('./project-bind-record.html?url')}">
                                {{packageItem.used_num}}
                            </span>
                        </td>
                        <td>可用：{{packageItem.total_num-packageItem.used_num}}</td>
                    </tr>
                    <tr>
                        <td height="40" colspan="4">
                            <span class="c-gray">租期：{{item.BeginOn?item.BeginOn.split(' ')[0]:''}} 至 {{item.EndOn?item.EndOn.split(' ')[0]:''}}</span>
                            <span ng-class="{'label-yellow':item.Status==1,'label-gray':item.Status==2 || item.Status==3}">{{item.Status==1?'激活':(item.Status==3?'过期':'作废')}}</span>
                        </td>
                    </tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</form>
